{block name="title"}<title>留言</title>{/block}
{block name="top"}<link rel="stylesheet" href="__CSS__/liuyan.css"> {/block}
{extend	name="index"	/}
{block name="right"}
        <div class="mid">
            <div class="mid_box">
                <div class="hd">
                    {volist name="list" id="to"}
                    <img src="__IMG__/6.png">
                    <span><a href="">tang0pan</a></span>
                    <ul class="title">
                        <li>
                            <img src="__IMG__/shijian.png">
                            <a >{:date('Y-m-d H:i',$to['time'])}</a>
                        </li>
                        <li>
                            <img src="__IMG__/yan.png">
                            <a >121108</a>
                        </li>
                        <li>
                            <img src="__IMG__/liu.png">
                            <a >2999</a>
                        </li>
                    </ul>
                    
                    <div class="ai">
                        <a >{$to.title}</a>
                        <span>{$to.title}</span>
                        <i>
                        {volist name="$to.img" id="vo"}
                        <img src="{$vo}">
                        {/volist}
                        </i>
                    </div>
                    <ul class="fabiao">
                        <li>
                            <a class="commit"><img src="__IMG__/pinglun.png"></a>
                            <span><a>评论2999</a></span>
                        </li>
                        <li>
                            <a onclick="zan()" > <img src="__IMG__/zan.png"></a>
                            <span><a>赞2999</a></span>
                        </li>
                        <li>
                            <a href=""> <img src="__IMG__/fatang.png"></a>
                            <span><a>发糖2999</a></span>
                        </li>
                    </ul>
                    {/volist}
                </div>   
            </div>
            <div class="di">
                <div class="dibu">
                    <span><a>全部评论</a></span>
                    <div class="pinglun">
                        
                    </div>
                </div>

               <div class="bg">
                    <div class="screen_box">
                        <div class="screen_title">
                            <p>评论</p>
                            <a href="" id="close" class="close">X</a>
                        </div>
                        <div name="" id="" cols="60" rows="10" class="comment_content" contenteditable="true";></div>
                        <div class="publish">
                                
                                <i class="publish_face"></i>
                                <div class="qq">
                                    <span ><i  class="guan">X</i></span>
                                    {for start='1' end='132'}
                                    <p onclick=upFace(this)>
                                        <img src="__QQ__/{$i}.gif">
                                    </p>
                                    {/for}
                                </div>
                            
                           
                            <input type="file" name="img" class="img" onchange="upImg(this)">
                            <i class="publish_img"></i>
                            <div id="img_show" class="img_show"></div>
                            <button class="up" onclick="publish()">评论</button>
                        </div>
                    </div>
               </div>

               <div class="tg">
                    <div class="huifu_box">
                        <div class="huifu_title">
                            <p>回复</p>
                            <a href="" id="close1" class="close1">X</a>
                        </div>
                        <div name="" id="" cols="60" rows="10" class="huifu_content" contenteditable="true";></div>
                        <div class="dian">
                                
                                <i class="dian_face"></i>
                                <div class="qq">
                                    <span ><i  class="guan1">X</i></span>
                                    {for start='1' end='132'}
                                    <p onclick=upFace(this)>
                                        <img src="__QQ__/{$i}.gif">
                                    </p>
                                    {/for}
                                </div>
                            
                           
                            <input type="file" name="img" class="img" onchange="upImg1(this)">
                            <i class="publish_img"></i>
                            <div id="img_show" class="img_show"></div>
                            <button class="up" onclick="publish1()">回复</button>
                        </div>
                    </div>
               </div>
               
            </div>
            <script src="__JS__/jquery-3.2.1.min.js"></script>
            <!-- <script>
                function zan(){
                    varlove=$(this);
                    varid=love.attr("rel");//对应id
                    love.fadeOut(300);//渐隐效果
                    $.ajax({
                        url:"{:Url('home/liuyan/zan')}",
                        data:"id="+id,
                        dataType:'html',
                        type:'get',
                        cache:false,//不缓存此页面
                        success:function(data){
                            love.html(data);
                            love.fadeIn(300);//渐显效果
                        },
                    }) 
                }
            </script> -->
            <script>
                $('.commit').on('click',function(){
                   $('.bg').fadeIn('slow')
                })
                $('#close').on('click',function(){
                   $('#close').fadeOut('slow')
                })
                $('.publish_face').on('click',function(){
                    $('.qq').slideDown()
                })
                $('.guan').on('click',function(){
                    $('.qq').slideUp()
                })
                function upFace(obj){
                    $('.comment_content').append($(obj).html())
                    $('.qq').slideUp()
                }
                function upImg(obj)
                        {
                        if( obj.value == "" ) {
                            return;
                        }
                        var formdata = new FormData(); 
                        //<input type="file" name="img" />
                        formdata.append("img" , $(obj)[0].files[0]);//获取文件法二
                        $.ajax({
                            type : 'post',
                            url : "{:Url('home/liuyan/upload')}",
                            data : formdata,
                            cache : false,
                            processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
                            contentType : false, // 不设置Content-type请求头
                            success : function(ret){
                                var html='<img src="'+ret+'" alt="" width="100px" height="100px">'
                                $('.comment_content').append(html);
                            },
                            error : function(){ }
                        });

                    }
                function delImg(obj){
                    $(obj).parent().remove()
                }
                function publish(){
                    $.ajax({
                        url:"{:Url('home/liuyan/addCommit')}",
                        data:{content:$('.comment_content').html()},
                        dataType:'html',
                        type:'get',
                        success:function(data){
                           $('.bg').fadeOut('slow')
                        },
                    })
                }
            </script>

          
    <script>
        function answer(obj){
            // $.post('{:Url("home/liuyan/huifuList")}',{liuyan_id:obj},function(data){
            //         console.log(data)
            //     })
           $('.tg').fadeIn('slow')
        }
        $('#close1').on('click',function(){
           $('.tg').fadeOut('slow')
        })
        $('.dian_face').on('click',function(){
            $('.qq').slideDown()
        })
        $('.guan1').on('click',function(){
            $('.qq').slideUp()
        })
        function upFace(obj){
            $('.huifu_content').append($(obj).html())
            $('.qq').slideUp()
        }
        function upImg1(obj)
                {
                if( obj.value == "" ) {
                    return;
                }
                var formdata = new FormData(); 
                //<input type="file" name="img" />
                formdata.append("img" , $(obj)[0].files[0]);//获取文件法二
                $.ajax({
                    type : 'post',
                    url : "{:Url('home/liuyan/upload1')}",
                    data : formdata,
                    cache : false,
                    processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
                    contentType : false, // 不设置Content-type请求头
                    success : function(ret){
                        var html='<img src="'+ret+'" alt="" width="100px" height="100px">'
                        $('.dian_content').append(html);
                    },
                    error : function(){ }
                });

            }
        function delImg1(obj){
            $(obj).parent().remove()
        }
        function publish1(){
            $.ajax({
                url:"{:Url('home/liuyan/addHuifu')}",
                data:{huifu:$('.huifu_content').html()},
                dataType:'html',
                type:'get',
                success:function(data){
                   $('.tg').fadeOut('slow')
                },
            })
        }
    </script>

            
            <script type="text/javascript" src="__JS__/template-native.js"></script>

            <script type="text/html" id="comment-list">
            <%for(var i=0;i < data.length;i++) {%>
                <div class="pinglun">
                   
                    <a class="tou" href=""> <img src="__IMG__/youxiang.png"></a> 
                    
                    <div class="dibu1">
                        <a href="">有趣的1999 </a>
                        <p>来自 OPPO R11.反正都精彩</p>
                        <span><%=getDate(data[i].time)%></span>
                        <div class="nei"><a href=""><%=#data[i].content%>  </a></div>
                    </div>
                    
                    <div class="dibu2">
                        <a ><%=#data[i].huifucontent%> <%=getDate(data[i].times)%> </a>
                    </div>
                    <div class="dibu3">.id%>)"> <img src="__IMG__/liu.png"></a>
                            <p><a>0</a></p>
                        <li>
                            <a onclick="answer(<%=data[i])">
                        </li>
                        <li>
                            <a href=""> <img src="__IMG__/xin.png"></a>
                            <p><a>0</a></p>
                        </li>
                        <li>
                            <a href=""> <img src="__IMG__/tang.png"></a>
                            <p><a>0</a></p>
                        </li>
                        <li style="margin-left:450px"><a href="" style="text-decoration: none;color:black;fone-size:14px;line-height:60px;">更多</a></li>
                    </div>
                </div>

            <%}%>
            </script>
           
            <script type="text/javascript">
            var pageno=1;
                function loadCommentList(){
                    $.post('{:Url("home/liuyan/contentList")}',{pageno:pageno},function(ret){
                        if(ret.code==1){
                            template.helper('getDate', function (time) {
                                return getLocalTime(time);
                            });

                            var html=template('comment-list',ret);
                            $('.pinglun').append(html);
                            // console.log(ret);
                        }
                    })
                }
                loadCommentList();
            </script>
            <script type="text/javascript">
                var pageno=1;
                    function loadHuifuList(){
                        $.post('{:Url("home/liuyan/huifuList")}',{pageno:pageno},function(ret){
                            if(ret.code==1){
                                template.helper('getDate', function (time) {
                                    return getLocalTime(time);
                                });
    
                                var html=template('comment-list',ret);
                                $('.pinglun').append(html);
                                // console.log(ret);
                            }
                        })
                    }
                    loadHuifuList();
                </script>
        {/block}
    